﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>FileGetVersion - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The FileGetVersion function retrieves the version of a file." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>FileGetVersion</h1>

<p>检索文件的版本.</p>

<pre class="Syntax">Version := <span class="func">FileGetVersion</span>(<span class="optional">Filename</span>)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>Filename</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>目标文件名. 如果未指定完整路径, 则此函数使用系统 <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175">LoadLibrary</a> 函数所指定的搜索顺序. 如果省略, 则将使用括在 <a href="LoopFiles.htm">File-Loop</a> 最内层的当前文件.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
<p>函数返回指定文件的版本号.</p>

<h2 id="Error_Handling">错误处理</h2>
<p>失败时抛出 <a href="Error.htm#OSError">OSError</a>, 例如文件缺少版本信息.</p>
<p><a href="../Variables.htm#LastError">A_LastError</a> 设置为操作系统 GetLastError() 函数的结果.</p>

<h2 id="Remarks">备注</h2>
<p>大多数非可执行文件(甚至一些 exe 文件) 都没有版本, and thus an error will be thrown.</p>
<h2 id="Related">相关</h2>
<p><a href="FileGetAttrib.htm">FileGetAttrib</a>, <a href="FileSetAttrib.htm">FileSetAttrib</a>, <a href="FileGetTime.htm">FileGetTime</a>, <a href="FileSetTime.htm">FileSetTime</a>, <a href="FileGetSize.htm">FileGetSize</a>, <a href="LoopFiles.htm">File-loop</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a class="ex_number" href="#ExBasic"></a> 读取文件的版本, 并将其存储在 <var>Version</var>.</p>
<pre>Version := FileGetVersion("C:\My Application.exe")</pre>
</div>

<div class="ex" id="ExBIV">
<p><a class="ex_number" href="#ExBIV"></a> 检索位于 AutoHotkey 安装目录下的文件 "AutoHotkey.exe" 的版本, 并将其存储在 <var>Version</var>.</p>
<pre>Version := FileGetVersion(A_ProgramFiles "\AutoHotkey\AutoHotkey.exe")</pre>
</div>	</div>

</body>
</html>